<!DOCTYPE html>
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<html>
<head>
    <meta charset="utf-8">
    <title>型号代号信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdXhdhTable" lay-filter="wQbdXhdhTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdXhdhHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm fillBtn" lay-event="add">
                <span>新增</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="delete">
                <span>删除</span>
            </a>
            <!--            <a class="layui-btn layui-btn-sm" lay-event="export">-->
            <!--                <i class="layui-icon layui-icon-export"></i>-->
            <!--                <span>导出</span>-->
            <!--            </a>-->
            <!--            <a class="layui-btn layui-btn-sm" lay-event="import">-->
            <!--                <i class="layui-icon layui-icon-download-circle"></i>-->
            <!--                <span>导入</span>-->
            <!--            </a>-->
            <!--<a class="layui-btn layui-btn-sm" lay-event="query">
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="clears">
                <span>重置</span>
            </a>-->
        </div>
        <form class="layui-form" action="" lay-filter="wQbdXhdhQueryForm">
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号代号</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_fModelcode_SL" maxlength="50"
                                   placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_fModelname_SL" maxlength="50"
                                   placeholder="请输入"/>
                        </div>
                    </div>

                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <!-- <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                             <i class="iconfont iconangle-down screen"></i>
                         </button>-->
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdXhdhRightToolsBar">
    <a class="RightBtn" lay-event="edit">编辑</a>
    <a class="RightBtn" lay-event="particulars">详情</a>
    <a class="RightBtn" lay-event="del">删除</a>
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'setter', 'form', 'common', 'publicMethods', 'jquery', 'layer'], function () {
        var table = layui.table;
        var setter = layui.setter;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        common.tableSort('wQbdXhdhTable');

        var tableH = publicMethods.tabHeight();

        //第一个实例
        table.render({
            elem: '#wQbdXhdhTable'
            , height: tableH
            , url: '${ctx}/qbdms/wQbdXhdh/list'
            , page: publicMethods.pageFun() //开启分页
            , toolbar: '#wQbdXhdhHeaderToolsBar'
            , defaultToolbar: ['']
            , method: 'post'
            , limit: 20
            , autoSort: false //是否排序
            , cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                , {field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                // ,{field: 'id', title: '主键',sort:true, sortname: 'id'}
                // ,{field: 'fFillman', title: '填写人',sort:true, sortname: 'f_fillman'}
                // ,{field: 'fFillmanaccount', title: '填写人账号',sort:true, sortname: 'f_fillmanaccount'}
                // ,{field: 'fFilldept', title: '填写部门',sort:true, sortname: 'f_filldept'}
                // ,{field: 'fFilldeptid', title: '填写部门id',sort:true, sortname: 'f_filldeptid'}
                // ,{field: 'fFilldate', title: '填写日期',sort:true, sortname: 'f_filldate'}
                , {field: 'fModelcode', title: '型号代号', sort: false, sortname: 'f_modelcode', minWidth: '200'}
                , {field: 'fModelname', title: '型号名称', sort: false, sortname: 'f_modelname', minWidth: '200'}
                // ,{field: 'fSecret', title: '密级',sort:true, sortname: 'f_secret'}
                // ,{field: 'tenantId', title: '租户Id',sort:true, sortname: 'tenantid'}
                // ,{field: 'createBy', title: '创建人',sort:true, sortname: 'createby'}
                //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.createTime,"1");
                //如需转换为HH:mm:ss: return publicMethods.timeData(d.createTime,"2");
                // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.createTime);
                // ,{field: 'createTime', title: '创建时间',sort:true, sortname: 'createtime',templet: function (d) {
                //     return publicMethods.timeData(d.createTime);
                // }}
                // ,{field: 'updateBy', title: '更新人',sort:true, sortname: 'updateby'}
                //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.updateTime,"1");
                //如需转换为HH:mm:ss: return publicMethods.timeData(d.updateTime,"2");
                // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.updateTime);
                // ,{field: 'updateTime', title: '更新时间',sort:true, sortname: 'updatetime',templet: function (d) {
                //     return publicMethods.timeData(d.updateTime);
                // }}
                , {
                    fixed: 'right',
                    title: '管理',
                    toolbar: '#wQbdXhdhRightToolsBar', minWidth: '200'
                }
            ]], done: function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input', 'a[lay-event=query]', '.ccpui-enterSel');
            }
        });

        dateReflash()

        function dateReflash() {
            publicMethods.reflashDate({startName: '.start_time1', endName: '.end_time1'});
            publicMethods.reflashDate({startName: '.start_time2', endName: '.end_time2'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdXhdhTable", "wQbdXhdhQueryForm", {where: {}}, isClear);
        }

        table.on('toolbar(wQbdXhdhTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = "${ctx}/qbdms/wQbdXhdh/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array += data[i].id + ",";
                    }
                    delFun(data, array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'), {
                            title: false,
                            skin: 'confirm-class'
                        }, function (index) {
                            btn: ['确定', '取消'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var url = '${ctx}/qbdms/wQbdXhdh/exportData';
                            $("form[lay-filter='wQbdXhdhQueryForm']").find(".filter-value").each(function (i, value) {
                                if (i == 0) {
                                    url += "?" + this.name + "=" + this.value
                                } else {
                                    url += "&" + this.name + "=" + this.value
                                }
                            });
                            window.location.href = url;
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'), {
                            title: false,
                            skin: 'confirm-class'
                        }, function (index) {
                            btn: ['是', '否'] //按钮
                        }, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = '${ctx}/qbdms/wQbdXhdh/exportData?id=' + ids;
                            window.location.href = url;
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdXhdhTable', "/qbdms/wQbdXhdh/importData", false, "");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdXhdhTable');
                    dateReflash();
                    form.render();
                    break;
            }
            ;
        });

        table.on('tool(wQbdXhdhTable)', function (obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch (layEvent) {
                case "edit":
                    window.location.href = '${ctx}/qbdms/wQbdXhdh/view/add?id=' + data.id
                    break;
                case "particulars":
                    window.location.href = '${ctx}/qbdms/wQbdXhdh/view/particulars?id=' + data.id;
                    break;
                case "del":
                    delFun(data, data.id);
                    break;
            }
        });

        function delFun(data, id) {
            if (data.length === 0) {
                layer.msg('请先选择一行数据!',{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'), {
                    title: false,
                    skin: 'confirm-class'
                }, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: "${ctx}/qbdms/wQbdXhdh/del",
                        type: "post",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
        };
        /*刷新时间控件*/
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdSoftwareStaTable', true);
        dateReflash();
        common.tableSort("wQbdXhdhTable");
    });
</script>
</body>
</html>